<template>
  <div class="daily">
    <div class="nav">
      <van-nav-bar
        title="每日推荐"
        left-text="返回"
        left-arrow
        @click-left="onClickLeft"
      />

      <van-swipe class="my-swipe" :autoplay="3000" indicator-color="white">
        <van-swipe-item
          ><img class="swipe" src="./img/1.png" alt=""
        /></van-swipe-item>
        <van-swipe-item
          ><img class="swipe" src="./img/2.png" alt=""
        /></van-swipe-item>
        <van-swipe-item
          ><img class="swipe" src="./img/3.png" alt=""
        /></van-swipe-item>
        <van-swipe-item
          ><img class="swipe" src="./img/4.png" alt=""
        /></van-swipe-item>
        <van-swipe-item
          ><img class="swipe" src="./img/5.png" alt=""
        /></van-swipe-item>
      </van-swipe>
    </div>

    <div class="play">
      <van-icon name="play-circle-o" size="21" color="red" />
      <span class="play1">播放全部</span>

      <b> <van-icon name="certificate" /> </b>
    </div>

    <ul>
      <li v-for="item in dailySongs" :key="item.id" @click="godailt(item.id)">
        <img class="img" :src="item.al.picUrl" alt="" />
        <div>
          <div>
            <p>{{ item.name }}</p>
          </div>
          <div v-for="v in item.ar" :key="v.id" class="div">
            <span> {{ v.name }} -- {{ item.name }}</span>
          </div>
        </div>
        <div class="right">
          <van-icon name="play-circle-o" size="21" color="#B3B3B3" />
          <van-icon name="weapp-nav" class="weapp" />
        </div>
      </li>
    </ul>
  </div>
</template>

<script>
import axios from "axios";
export default {
  data() {
    return {
      dailySongs: "",
    };
  },
  computed: {},
  watch: {},

  methods: {
    async initlist() {
      axios
        .get("http://localhost:3000/recommend/songs", {
          withCredentials: true, //cookie跨域
        })
        .then((res) => {
          console.log("每日推荐", res);
          this.dailySongs = res.data.data.dailySongs;
          console.log(this.dailySongs);
        });
    },
    onClickLeft() {
      this.$router.go(-1);
    },
    godailt(id) {
      this.$router.push(`/songdetail/${id}`);
    },
  },
  created() {
    console.log(this.dailySongs);
  },
  mounted() {
    this.initlist();
  },
  components: {},
};
</script>
<style scoped>
.img {
  width: 80px;
  height: 80px;
  margin-right: 15px;
  border-radius: 10px;
}
.div {
  height: 80px;
  line-height: 80px;
  color: rgb(134, 133, 133);
  width: 230px;
  overflow: hidden;
  /*文本不换行*/
  white-space: nowrap;
  /*文字超出用省略号*/
  text-overflow: ellipsis;
}
p {
  font-size: 20px;
  width: 200px;
  overflow: hidden;
  /*文本不换行*/
  white-space: nowrap;
  /*文字超出用省略号*/
  text-overflow: ellipsis;
}

li {
  display: flex;
  margin-top: 20px;
  margin-left: 15px;
  position: relative;
}
ul {
  margin-bottom: 40px;
}
.right {
  /* display: flex; */
  position: absolute;
  right: 0px;
  top: 20px;
}
.van-icon:before {
  margin-left: 15px;
  /* margin-right: 10px; */
  font-size: 25px;
}
.img1 {
  width: 100%;
  height: 300px;
  /* position: fixed;
  top: 0; */
  z-index: -1;
}
.nav {
  width: 100%;
  height: 250px;
}
.my-swipe .van-swipe-item {
  color: #fff;
  font-size: 20px;
  line-height: 150px;
  text-align: center;
  background-color: #39a9ed;
  height: 200px;
}
.swipe {
  width: 100%;
  height: 200px;
}
.play {
  margin: 20px 0;
  position: relative;
}
.play1 {
  font-size: 25px;
  margin-left: 10px;
}
.play b {
  position: absolute;
  right: 15px;
  font-size: 30px;
}
</style>
